package org.microser.gataway.zuul.system.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.netflix.discovery.converters.Auto;
import org.microser.gataway.zuul.system.entity.Role;
import org.microser.gataway.zuul.system.mapper.RoleMapper;
import org.microser.gataway.zuul.system.service.RoleService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.microser.gataway.zuul.system.service.UserRoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author liujiamiao
 * @since 2020-11-25
 */
@Service
public class RoleServiceImpl extends ServiceImpl<RoleMapper, Role> implements RoleService {

    @Autowired
    private UserRoleService userRoleService;

    /**
     * 根据用户id获取角色
     * @param id
     * @return
     */
    @Override
    public List<Role> queryRoleListByUserId(String id) {
        List<String> roleIds = userRoleService.queryRoleIdsByUserId(id);
        List<Role> roles = baseMapper.selectBatchIds(roleIds);
        return roles;
    }
}
